package com.tjsinfo.tjsoa.system.action;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemChangYongYuBO;
import com.tjsinfo.tjsoa.system.vo.User;

public class ChangYongYuAction extends Action {
	private ISystemChangYongYuBO systemChangYongYuBo;

	public void setSystemChangYongYuBo(ISystemChangYongYuBO systemChangYongYuBo) {
		this.systemChangYongYuBo = systemChangYongYuBo;
	}

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			String nodeId=request.getParameter("nodeId");if(nodeId==null)nodeId="0";
			HttpSession session=request.getSession();
			User user=(User)session.getAttribute("user");
			List<String> list=systemChangYongYuBo.getUserChangYongYu(nodeId, user.getUser_id());
			String temp=",";
			for (String string : list) {
				temp=temp+string+",";
			}
			response.getWriter().print(temp);
			return mapping.findForward(null);
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("Exception", e);
			return mapping.findForward("failed");
		}
	}
}
